#include<iostream>  
#include<cstdlib>
#include<fstream>    
#include<cctype>      
#include<iomanip>  

#include "Administrator.h"
#include "Client.h"
using namespace std;



void intro()
{
	cout << "\n\n\n\t\t\t\t\t Welcome To BANKING MANAGEMENT SYSTEM";
	cout << "\n\n\t\t\t\t Presented By Mohsinul Kabir,Dhruba Fahim,Naeer Amin";

	cout << "\n\n\n\t\t\t\t\t Press Enter To Continue........";
	cin.get();
}

void Admin_intro()
{
	system("cls");
	cout << "\n\n\t\t\tWelcome to Admin Panel\n\n\n\t\t\tPress any key to continue....";
	cin.get();
	cin.get();
	int choice;
	int num1;
	Administrator ad;

	do
	{
		system("cls");   //Clear The Screen
		cout << "\n\n\n\t\t\tACTION MENU";
		cout << "\n\n\t01. CREATE NEW ACCOUNT";


		cout << "\n\n\t02. COMPLETE ACCOUNT HOLDERS LIST";
		cout << "\n\n\t03. CLOSE AN ACCOUNT";
		cout << "\n\n\t04. MODIFY AN ACCOUNT";
		cout << "\n\n\t05. EXIT";
		cout << "\n\n\tSelect Your Option (1-5): ";
		cin >> choice;
		if (choice > 5 || choice < 1)
		{
			system("cls");
			cout << "\n Invalid Input, Please Try Again";
			cin.get();
			cin.get();
			continue;
		}
		else{
			switch (choice)
			{
			case 1:

				system("cls");
				ad.write_account();
				break;
			case 2:
				system("cls");
				ad.display_all();
				break;

			case 3:
				system("cls");
				cout << "\n\n\tEnter The Account Number : "; cin >> num1;
				ad.delete_account(num1);
				break;

			case 4:
				system("cls");
				cout << "\n\n\tEnter The Account Number : "; cin >> num1;
				ad.modify_account(num1);
				break;

			case  5:
				system("cls");
				cout << "\n\n\tThanks For Visiting Our Bank!";

			}
		}
	} while (choice != 5);
}


void client_intro()
{

	Client cl;
	int cl_choice;
	int num, pass;

	do
	{
		system("cls");   //Clear The Screen
		cout << "\n\n\n\t\t\tACTION MENU";

		cout << "\n\n\n\t01. DEPOSIT";
		cout << "\n\n\n\t02. WITHDRAW";
		cout << "\n\n\n\t03. BALANCE ENQUIRY";

		cout << "\n\n\n\t04. EXIT";
		cout << "\n\n\n\tSelect Your Option (1-4): ";
		cin >> cl_choice;

		if (cl_choice > 4 || cl_choice < 1)
		{
			system("cls");
			cout << "\n Invalid Input, Please Try Again";
			cin.get();
			cin.get();
			continue;
		}

		else{
			switch (cl_choice)
			{
			case 1:
				system("cls");
				cout << "\n\n\tEnter The Account Number : "; cin >> num;
				cout << "\n\n\tEnter The Password : "; cin >> pass;

				cl.deposit_withdraw(num, 1, pass);
				break;

			case 2:
				system("cls");
				cout << "\n\n\tEnter The Account Number : "; cin >> num;
				cout << "\n\n\tEnter The Password : "; cin >> pass;

				cl.deposit_withdraw(num, 2, pass);
				break;

			case 3:
				system("cls");
				cout << "\n\n\tEnter The Account Number : "; cin >> num;
				cout << "\n\n\tEnter The Password : "; cin >> pass;
				cl.display_sp(num, pass);
				break;

			case  4:
				system("cls");
				cout << "\n\n\tThanks For Visiting Our Bank!";
				break;

			}
		}
	} while (cl_choice != 4);
}


int main()
{
	system("color 0C");
	int choice1, a;
	int admin_pass = 1234;
	intro();

	system("cls");
	cout << "\n\n\t\t\t Press 1 to Enter As Administrator (Password Protected): ";
	cout << "\n\n\t\t\t Press 2 to Enter As Client: ";
	cout << "\n\n\t\t\t Enter Your Choice: ";
	cin >> choice1;

	if (choice1 == 1){
		while (1)
		{
			cout << "\n\n\t\t\tEnter Admin Password:";
			cin >> a;
			if (a == admin_pass)
			{
				break;
			}
			else {
				cout << "\n\n\t\tPassword Wrong !! Please Re-enter Password...";
				cin.get();
				cin.get();
				continue;
			}
		}
		Admin_intro();
	}
	else if (choice1 == 2) client_intro();

	else if (choice1 > 2 || choice1 < 1)
	{
		system("cls");
		cout << "\n Invalid Input, Please Try Again";
		cin.get();


	}
	return 0;
}